package org.cursoexperto.jftf.entidades;

import java.io.Serializable;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Jose Fernando
 */
@Entity
@Table(name = "JFTF_VENTAS", catalog = "", schema = "SCOTT")
public class Venta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    private Long id;
    @Column(name = "FECHA")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @JoinColumn(name = "ID_CLIENTE", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private Cliente cliente;
    @OneToMany(mappedBy = "venta")
    private List<LineaVenta> carroCompra;


    public Venta() {
        carroCompra = new ArrayList<LineaVenta>();
    }

    /**
     * @return the carroCompra
     */
    public List<LineaVenta> getCarroCompra() {
        return carroCompra;
    }

    /**
     * @param carroCompra the carroCompra to set
     */
    public void setCarroCompra(List<LineaVenta> carroCompra) {
        this.carroCompra = carroCompra;
    }

    public List<LineaVenta> getLineaVentaList() {
        return carroCompra;
    }

    /**
     * @param carroCompra the carroCompra to set
     */
    public void setLineaVentaList(List<LineaVenta> carroCompra) {
        this.carroCompra = carroCompra;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the fecha
     */
    public String getFecha() {
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.FRANCE);
        return df.format(fecha);
    }

    public Date getFechaDate() {
        return fecha;
    }

    /**
     * @param fecha the fecha to set
     */
    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    /**
     * @return the cliente
     */
    public Cliente getCliente() {
        return cliente;
    }

    /**
     * @param cliente the cliente to set
     */
    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }


}